﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Drawing;
using System.IO;
using System.Text.RegularExpressions;
using System.Threading;
using System.Windows.Forms;
using XimalayaAudioDownloader.Properties;

namespace XimalayaAudioDownloader
{
    // Token: 0x02000007 RID: 7
    public partial class MainForm : Form
    {
        // Token: 0x06000055 RID: 85 RVA: 0x000035D4 File Offset: 0x000017D4
        public MainForm()
        {
            this.InitializeComponent();
            CheckForIllegalCrossThreadCalls = false;//忽略线程安全
        }


        private void MainForm_Load(object sender, EventArgs e)
        {
            bool flag = !Directory.Exists(AppDomain.CurrentDomain.BaseDirectory + "DownloadList");
            if (flag)
            {
                Directory.CreateDirectory(AppDomain.CurrentDomain.BaseDirectory + "DownloadList");
            }
            CommonMethds.InitialDownloadList(this.DownloadList);
            this.InitialArgs();
            Application.ThreadException += new ThreadExceptionEventHandler(this.Application_ThreadException);
            AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(this.CurrentDomain_UnhandledException);
            this.Text = "喜马拉雅音频批量下载器   By 明天会更好    |    默认下载位置：" + this.storePath;
        }


        private void Application_ThreadException(object sender, ThreadExceptionEventArgs e)
        {
            MessageBox.Show("出现未知错误，正确联网并重启程序后依然无法正常使用，请联系作者！", "错误", MessageBoxButtons.OK, MessageBoxIcon.Hand);
        }


        private void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
        {
            this.State.Text = "当前网络状况不佳，程序会在网络通畅后继续下载！";
        }


        private void InitialArgs()
        {
            ReadSetting readSetting = new ReadSetting();
            string path = readSetting.IniReadValue("AppSettings", "PathToStore");
            bool flag = !Directory.Exists(path);
            if (flag)
            {
                MessageBox.Show("请为程序设置默认下载目录！");
                bool flag2 = this.StoreFolderBrowserDialog.ShowDialog() == DialogResult.OK;
                if (flag2)
                {
                    readSetting.IniWriteValue("AppSettings", "PathToStore", this.StoreFolderBrowserDialog.SelectedPath);
                    this.storePath = this.StoreFolderBrowserDialog.SelectedPath;
                }
                else
                {
                    this.InitialArgs();
                }
            }
            else
            {
                this.storePath = path;
            }
        }

        // Token: 0x0600005A RID: 90 RVA: 0x00003780 File Offset: 0x00001980
        private void DownloadList_RowPrePaint(object sender, DataGridViewRowPrePaintEventArgs e)
        {
            bool flag = e.RowIndex % 2 == 1;
            if (flag)
            {
                this.DownloadList.Rows[e.RowIndex].DefaultCellStyle.BackColor = Color.PowderBlue;
            }
        }


        private void AnysisAndAddBtn_Click(object sender, EventArgs e)
        {
            this.SirialTree.Nodes.Clear();
            TreeNode treeNode = new TreeNode("专辑列表");
            treeNode.Name = "RootNode";
            treeNode.Checked = true;
            this.SirialTree.Nodes.Add(treeNode);
            bool flag = this.ResourceBox.Lines.Length != 0 && (this.ResourceBox.Text.IndexOf("ximalaya") > -1 || this.ResourceBox.Text.IndexOf("qingting") > -1 || this.ResourceBox.Text.IndexOf("lizhi") > -1);
            if (flag)
            {
                new Thread(new ThreadStart(this.getSound))
                {
                    IsBackground = true
                }.Start();
            }
            else
            {
                MessageBox.Show("请输入正确网址！");
            }
        }

        public delegate void Invok(string msg);
        public void log(string msg)
        {
            State.Text = msg;
        }
        public void InsertData(AudioInfo mod)
        {
            int index = this.DownloadList.Rows.Add();
            this.DownloadList.Rows[index].Cells[0].Value = true;
            this.DownloadList.Rows[index].Cells[1].Value = mod.id;
            this.DownloadList.Rows[index].Cells[2].Value = mod.album_title;
            this.DownloadList.Rows[index].Cells[3].Value = mod.title;
            this.DownloadList.Rows[index].Cells[4].Value = mod.play_path;
            this.DownloadList.Rows[index].Cells[5].Value = string.Concat(new object[]
            {
                                    int.Parse(mod.duration) / 60,
                                    "分",
                                    int.Parse(mod.duration) % 60,
                                    "秒"
            });
            this.DownloadList.Rows[index].Cells[6].Value = "";
            this.DownloadList.Rows[index].Cells[7].Value = "";
            this.DownloadList.Rows[index].Cells[8].Value = "0%";
        }
        private void getSound()
        {
            var _State = new Invok(log);

            this.classCount = 0;
            this.soundsCount = 0;
            string text = string.Empty;
            BeginInvoke(_State, new object[] { "正在分析网址，请稍等……" });
            for (int i = 0; i < this.ResourceBox.Lines.Length; i++)
            {
                var flag = this.ResourceBox.Lines[i].IndexOf("ximalaya") > -1;
                if (flag)
                {
                    string text2 = this.ResourceBox.Lines[i];
                    string httpWebRequest = CommonMethds.GetHttpWebRequest(text2);
                    //Regex regex = new Regex(@"-->(\d*)<", RegexOptions.IgnoreCase | RegexOptions.Multiline);
                    var regex = new Regex(@"""currentUid"":0,""albumId"":(\d*)", RegexOptions.IgnoreCase | RegexOptions.Multiline);
                    Match match = regex.Match(httpWebRequest);
                    var albumId = match.Groups[1].Value.Trim();
                    var albumInfo = CommonMethds.GetXMLYAlbumInfo(albumId);
                    if (albumInfo.ret == 200)
                    {
                        State.Text = $"专辑获取成功，准备分析内容";
                        var list = CommonMethds.GetAllXMLY(albumInfo);
                        State.Text = $"内容请求成功，准备分析曲目信息，共{list.Count}首";
                        for (int j = 0; j < list.Count; j++)
                        {
                            var audio = CommonMethds.GetAudioInfo(list[i].trackId);
                            audio.title = $"{i}-{j}" + audio.title;
                            InsertData(audio);
                            this.State.Text = $"正在分析第{i + 1},张专辑下载地址，已完成{j + 1}首，请稍等……";
                        }
                    }

                    else
                    {
                        MessageBox.Show("网络错误");
                    }
                }
                else
                {
                    bool flag5 = this.ResourceBox.Lines[i].IndexOf("qingting") > -1;
                    if (flag5)
                    {
                        try
                        {
                            string text4 = this.ResourceBox.Lines[i];
                            string url2 = text4.Replace("http://www.qingting.fm", "http://i.qingting.fm/wapi") + "/programs/page/1/pagesize/1";
                            string text5 = CommonMethds.GetHttpWebRequest(url2);
                            string text6 = text5.Remove(0, text5.IndexOf("\"total\":") + 8);
                            text6 = text6.Remove(text6.IndexOf("}"));
                            int num4 = int.Parse(text6);
                            url2 = text4.Replace("http://www.qingting.fm", "http://i.qingting.fm/wapi") + "/programs/page/1/pagesize/" + num4;
                            text5 = CommonMethds.GetHttpWebRequest(url2);
                            text5 = text5.Replace("{\"data\":[", "").Replace("],\"code\":0,\"total\":305}", "");
                            for (int l = 0; l < num4; l++)
                            {
                                string text7 = CommonMethds.getQingtingSoundByIndex(text5, l + 1) + "}";
                                string text8 = text7.Remove(0, text7.IndexOf("{\"res_id\":") + 10);
                                text8 = text8.Remove(text8.IndexOf(","));
                                string text9 = text7.Remove(0, text7.IndexOf("duration") + 10);
                                text9 = text9.Remove(text9.IndexOf(","));
                                int num5 = (int)float.Parse(text9);
                                string text10 = text7.Remove(0, text7.IndexOf("channel_id") + 13);
                                text10 = text10.Remove(text10.IndexOf("\","));
                                string text11 = text7.Remove(0, text7.IndexOf("file_path") + 17);
                                text11 = text11.Remove(text11.IndexOf("\","));
                                text11 = "http://od.qingting.fm/m4a/" + text11;
                                string text12 = text7.Remove(0, text7.IndexOf("name") + 7);
                                text12 = text12.Remove(text12.IndexOf("\","));
                                bool flag6 = text8 != "null";
                                if (flag6)
                                {
                                    this.soundsCount++;
                                    int index2 = this.DownloadList.Rows.Add();
                                    this.DownloadList.Rows[index2].Cells[0].Value = true;
                                    this.DownloadList.Rows[index2].Cells[1].Value = text8;
                                    this.DownloadList.Rows[index2].Cells[2].Value = text10;
                                    this.DownloadList.Rows[index2].Cells[3].Value = string.Concat(new object[]
                                    {
                                        "[",
                                        l + 1,
                                        "]",
                                        text12.Trim()
                                    });
                                    this.DownloadList.Rows[index2].Cells[4].Value = text11;
                                    this.DownloadList.Rows[index2].Cells[5].Value = string.Concat(new object[]
                                    {
                                        num5 / 60,
                                        "分",
                                        num5 % 60,
                                        "秒"
                                    });
                                    this.DownloadList.Rows[index2].Cells[6].Value = "";
                                    this.DownloadList.Rows[index2].Cells[7].Value = "";
                                    this.DownloadList.Rows[index2].Cells[8].Value = "0%";
                                }
                                this.State.Text = string.Concat(new object[]
                                {
                                    "正在分析第",
                                    i + 1,
                                    "张专辑下载地址，已完成",
                                    l + 1,
                                    "/",
                                    num4,
                                    "，请稍等……"
                                });
                            }
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show(ex.ToString());
                        }
                    }
                    else
                    {
                        bool flag7 = this.ResourceBox.Lines[i].IndexOf("lizhi") > -1;
                        if (flag7)
                        {
                            try
                            {
                                string text13 = this.ResourceBox.Lines[i];
                                string httpWebRequest2 = CommonMethds.GetHttpWebRequest(text13);
                                Regex regex2 = new Regex("(?m)<div class=\"box-title box-title-with-radio-controller\"[^>]*>(?<div>(?:\\w|\\W)*?)</div[^>]*>", RegexOptions.IgnoreCase | RegexOptions.Multiline);
                                Match match2 = regex2.Match(httpWebRequest2);
                                string text14 = match2.Groups["div"].Value.Trim();
                                text14 = text14.Remove(0, text14.IndexOf("</h2>（") + 6);
                                text14 = text14.Remove(text14.IndexOf("）<div"));
                                int num6 = int.Parse(text14);
                                int num7 = num6 / 20 + 1;
                                bool flag8 = text13.IndexOf("/p/") > -1;
                                if (flag8)
                                {
                                    text13 = text13.Remove(text13.IndexOf("p/"));
                                }
                                for (int m = 0; m < num7; m++)
                                {
                                    string tempUrl = string.Concat(new object[]
                                    {
                                        text13,
                                        "p/",
                                        m + 1,
                                        ".html"
                                    });
                                    CommonAudioInfo[] lizhiSounds = CommonMethds.GetLizhiSounds(tempUrl);
                                    bool flag9 = lizhiSounds != null;
                                    if (flag9)
                                    {
                                        for (int n = 0; n < lizhiSounds.Length; n++)
                                        {
                                            bool flag10 = lizhiSounds[n].FilePath != "";
                                            if (flag10)
                                            {
                                                this.soundsCount++;
                                                int index3 = this.DownloadList.Rows.Add();
                                                this.DownloadList.Rows[index3].Cells[0].Value = true;
                                                this.DownloadList.Rows[index3].Cells[1].Value = lizhiSounds[n].ID;
                                                this.DownloadList.Rows[index3].Cells[2].Value = lizhiSounds[n].SirialName;
                                                this.DownloadList.Rows[index3].Cells[3].Value = string.Concat(new object[]
                                                {
                                                    "[",
                                                    m * 20 + n + 1,
                                                    "]",
                                                    lizhiSounds[n].Title
                                                });
                                                this.DownloadList.Rows[index3].Cells[4].Value = lizhiSounds[n].FilePath;
                                                this.DownloadList.Rows[index3].Cells[5].Value = string.Concat(new object[]
                                                {
                                                    lizhiSounds[n].Duration / 60,
                                                    "分",
                                                    lizhiSounds[n].Duration % 60,
                                                    "秒"
                                                });
                                                this.DownloadList.Rows[index3].Cells[6].Value = "";
                                                this.DownloadList.Rows[index3].Cells[7].Value = "";
                                                this.DownloadList.Rows[index3].Cells[8].Value = "0%";
                                            }
                                            this.State.Text = string.Concat(new object[]
                                            {
                                                "正在分析第",
                                                i + 1,
                                                "张专辑下载地址，已完成",
                                                m * 20 + n,
                                                "/",
                                                num6,
                                                "，请稍等……"
                                            });
                                        }
                                    }
                                    else
                                    {
                                        this.State.Text = "请查看网络是否正常，或输入网址是否正确！";
                                    }
                                }
                            }
                            catch (Exception ex2)
                            {
                                MessageBox.Show(ex2.ToString());
                            }
                        }
                    }
                }

                this.StartBtn.Enabled = true;
                this.SirialTree.ExpandAll();
                this.classCount = this.SirialTree.Nodes.Count + 1;
                bool flag11 = this.soundsCount != 0;
                if (flag11)
                {
                    this.State.Text = string.Concat(new object[]
                    {
                    "成功添加",
                    this.classCount,
                    "张专辑，",
                    this.soundsCount,
                    "个音频文件。"
                    });
                }
                else
                {
                    this.State.Text = "请查看网络是否正常，或输入网址是否正确！";
                }
                this.UpdateTreeView();
                bool flag12 = this.ResourceBox.Lines.Length > this.soundsCount;
                if (flag12)
                {
                    MessageBox.Show("分析完毕，但是部分网址不正确，请注意！");
                }
            }
        }
        // Token: 0x0600005D RID: 93 RVA: 0x00004694 File Offset: 0x00002894
        private void UpdateTreeView()
        {
            bool invokeRequired = base.InvokeRequired;
            if (invokeRequired)
            {
                base.Invoke(new MainForm.DeleUpdateTreeView(this.UpdateTreeView), new object[0]);
            }
            else
            {
                TreeNode treeNode = this.SirialTree.Nodes["RootNode"];
                foreach (DataGridViewRow dataGridViewRow in ((IEnumerable)this.DownloadList.Rows))
                {
                    bool flag = !CommonMethds.haveNodeInTreeView(this.SirialTree, dataGridViewRow.Cells[2].Value.ToString().Trim());
                    if (flag)
                    {
                        TreeNode treeNode2 = new TreeNode(dataGridViewRow.Cells[2].Value.ToString().Trim());
                        treeNode2.Checked = true;
                        treeNode.Nodes.Add(treeNode2);
                    }
                }
                this.SirialTree.ExpandAll();
            }
            this.selectAll.Checked = true;
        }

        // Token: 0x0600005E RID: 94 RVA: 0x000047B8 File Offset: 0x000029B8
        private void ResourceBox_Enter(object sender, EventArgs e)
        {
            bool flag = this.ResourceBox.Text == "请输入专辑列表所在网址，类似\r\nhttp://www.ximalaya.com/7178199/album/243032\r\nhttps://www.lizhi.fm/250837/\r\nhttp://www.qingting.fm/channels/211544\r\n样式的资源网址，多个专辑请换行。";
            if (flag)
            {
                this.ResourceBox.Text = "";
            }
        }

        // Token: 0x0600005F RID: 95 RVA: 0x000047F0 File Offset: 0x000029F0
        private void ResourceBox_Leave(object sender, EventArgs e)
        {
            bool flag = this.ResourceBox.Text == "";
            if (flag)
            {
                this.ResourceBox.Text = "请输入专辑列表所在网址，类似\r\nhttp://www.ximalaya.com/7178199/album/243032\r\nhttps://www.lizhi.fm/250837/\r\nhttp://www.qingting.fm/channels/211544\r\n样式的资源网址，多个专辑请换行。";
                this.AnysisAndAddBtn.Enabled = false;
            }
        }

        // Token: 0x06000060 RID: 96 RVA: 0x00004837 File Offset: 0x00002A37
        private void ClearDownloadList_Click(object sender, EventArgs e)
        {
            this.DownloadList.Rows.Clear();
            MessageBox.Show("下载列表已清空");
        }

        // Token: 0x06000061 RID: 97 RVA: 0x00004858 File Offset: 0x00002A58
        private void SelectFilePath_Click(object sender, EventArgs e)
        {
            bool flag = this.StoreFolderBrowserDialog.ShowDialog() == DialogResult.OK;
            if (flag)
            {
                ReadSetting readSetting = new ReadSetting();
                readSetting.IniWriteValue("AppSettings", "PathToStore", this.StoreFolderBrowserDialog.SelectedPath);
                this.storePath = this.StoreFolderBrowserDialog.SelectedPath;
                MessageBox.Show("设置下载位置成功！");
            }
        }

        // Token: 0x06000062 RID: 98 RVA: 0x000048B8 File Offset: 0x00002AB8
        private void OpenFilePath_Click(object sender, EventArgs e)
        {
            Process.Start("explorer.exe", this.storePath);
        }

        // Token: 0x06000063 RID: 99 RVA: 0x000048CC File Offset: 0x00002ACC
        private void StartBtn_Click(object sender, EventArgs e)
        {
            this.isStop = false;
            this.StartBtn.Enabled = false;
            this.StopBtn.Enabled = true;
            this.State.Text = "开始下载！";
            this.userStop = false;
            new Thread(new ThreadStart(this.download))
            {
                IsBackground = true
            }.Start();
        }

        // Token: 0x06000064 RID: 100 RVA: 0x00004934 File Offset: 0x00002B34
        private void download()
        {
            foreach (DataGridViewRow dataGridViewRow in ((IEnumerable)this.DownloadList.Rows))
            {
                bool flag = this.userStop;
                if (flag)
                {
                    this.StartBtn.Enabled = true;
                    this.State.Text = "下载已停止！";
                    break;
                }
                bool flag2 = !Directory.Exists(this.storePath + "\\" + dataGridViewRow.Cells[2].Value.ToString() + "\\");
                if (flag2)
                {
                    Directory.CreateDirectory(this.storePath + "\\" + dataGridViewRow.Cells[2].Value.ToString() + "\\");
                }
                string filename = string.Concat(new string[]
                {
                    this.storePath,
                    "\\",
                    dataGridViewRow.Cells[2].Value.ToString(),
                    "\\",
                    dataGridViewRow.Cells[3].Value.ToString(),
                    ".mp3"
                });
                bool flag3 = (bool)dataGridViewRow.Cells[0].Value && (string)dataGridViewRow.Cells[8].Value != "100%" && this.State.Text != "网络连接超时，请稍后重试！(Error3)";
                if (flag3)
                {
                    this.State.Text = string.Concat(new object[]
                    {
                        "当前下载(",
                        dataGridViewRow.Index,
                        "/",
                        this.DownloadList.Rows.Count,
                        ")：",
                        dataGridViewRow.Cells[3].Value.ToString(),
                        ".mp3"
                    });
                    CommonMethds.DownloadFile(dataGridViewRow.Cells[4].Value.ToString(), filename, dataGridViewRow, this.State);
                }
                bool flag4 = this.State.Text == "网络连接超时，请检查网络连接后重试！(Error3)";
                if (flag4)
                {
                    this.StartBtn.Enabled = true;
                    this.StopBtn.Enabled = false;
                    this.isStop = true;
                    break;
                }
            }
            this.StopBtn.Enabled = false;
            bool flag5 = this.State.Text != "网络连接超时，请检查网络连接后重试！(Error3)";
            if (flag5)
            {
                this.State.Text = "下载完成！";
            }
            bool flag6 = !this.isStop && this.AutoPowerDown.Checked;
            if (flag6)
            {
                Process.Start(new ProcessStartInfo
                {
                    UseShellExecute = false,
                    FileName = "shutdown.exe",
                    Arguments = "-s -t 30",
                    CreateNoWindow = true,
                    RedirectStandardError = true,
                    RedirectStandardInput = true,
                    RedirectStandardOutput = true
                });
            }
        }


        private void LoadDownLoadList_Click(object sender, EventArgs e)
        {
            this.openXmlFileDialog.InitialDirectory = AppDomain.CurrentDomain.BaseDirectory + "DownloadList";
            bool flag = this.openXmlFileDialog.ShowDialog() == DialogResult.OK;
            if (flag)
            {
                CommonMethds.Xml2DataGridView(this.DownloadList, this.SirialTree, this.openXmlFileDialog.FileName);
                this.SirialTree.ExpandAll();
                this.StartBtn.Enabled = true;
            }
        }

        private void DownloadList_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            bool flag = e.ColumnIndex == 0;
            if (flag)
            {
                this.DownloadList.Rows[e.RowIndex].Cells[0].Value = !(bool)this.DownloadList.Rows[e.RowIndex].Cells[0].Value;
            }
        }


        private void selectAll_CheckedChanged(object sender, EventArgs e)
        {
            foreach (DataGridViewRow dataGridViewRow in ((IEnumerable)this.DownloadList.Rows))
            {
                dataGridViewRow.Cells[0].Value = this.selectAll.Checked;
            }
        }


        private void AutoTry_CheckedChanged(object sender, EventArgs e)
        {
            this.timer1.Enabled = this.AutoTry.Checked;
        }


        private void StopBtn_Click(object sender, EventArgs e)
        {
            this.StopBtn.Enabled = false;
            this.State.Text = "程序将在完成当前下载任务后停止。";
            this.userStop = true;
        }


        private void SaveDownLoadList_Click(object sender, EventArgs e)
        {
            bool flag = this.DownloadList.Rows.Count > 0;
            if (flag)
            {
                this.saveXmlFileDialog.InitialDirectory = AppDomain.CurrentDomain.BaseDirectory + "DownloadList";
                this.saveXmlFileDialog.FileName = DateTime.Now.ToLongDateString().ToString() + ".xml";
                bool flag2 = this.saveXmlFileDialog.ShowDialog() == DialogResult.OK;
                if (flag2)
                {
                    CommonMethds.DataGridView2Xml(this.DownloadList, this.saveXmlFileDialog.FileName);
                }
            }
            else
            {
                MessageBox.Show("下载列表为空！");
            }
        }


        private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
        {
            bool flag = this.DownloadList.Rows.Count > 0;
            if (flag)
            {
                bool flag2 = MessageBox.Show("退出前是否保存下载列表？", "系统提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes;
                if (flag2)
                {
                    this.saveXmlFileDialog.InitialDirectory = AppDomain.CurrentDomain.BaseDirectory + "DownloadList";
                    this.saveXmlFileDialog.FileName = DateTime.Now.ToLongDateString().ToString() + ".xml";
                    bool flag3 = this.saveXmlFileDialog.ShowDialog() == DialogResult.OK;
                    if (flag3)
                    {
                        CommonMethds.DataGridView2Xml(this.DownloadList, this.saveXmlFileDialog.FileName);
                    }
                }
            }
        }


        private void timer1_Tick(object sender, EventArgs e)
        {
            bool flag = this.isStop;
            if (flag)
            {
                this.StartBtn_Click(sender, e);
            }
        }


        private void SirialTree_MouseClick(object sender, MouseEventArgs e)
        {
            TreeNode nodeAt = this.SirialTree.GetNodeAt(new Point(e.X, e.Y));
            bool flag = nodeAt.Text != "专辑列表";
            if (flag)
            {
                foreach (DataGridViewRow dataGridViewRow in ((IEnumerable)this.DownloadList.Rows))
                {
                    bool flag2 = dataGridViewRow.Cells[2].Value.ToString() == nodeAt.Text;
                    if (flag2)
                    {
                        dataGridViewRow.Cells[0].Value = nodeAt.Checked;
                    }
                }
                bool flag3 = nodeAt != null;
                if (flag3)
                {
                    this.ChangeChild(nodeAt, nodeAt.Checked);
                    this.ChangeParent(nodeAt);
                }
            }
        }


        private void ChangeChild(TreeNode node, bool state)
        {
            node.Checked = state;
            foreach (TreeNode node2 in node.Nodes)
            {
                this.ChangeChild(node2, state);
            }
        }


        private void ChangeParent(TreeNode node)
        {
            bool flag = node.Parent != null;
            if (flag)
            {
                int num = 0;
                foreach (TreeNode treeNode in node.Parent.Nodes)
                {
                    bool @checked = treeNode.Checked;
                    if (@checked)
                    {
                        num++;
                    }
                }
                bool flag2 = num == 0;
                if (flag2)
                {
                    node.Parent.Checked = false;
                    this.ChangeParent(node.Parent);
                }
                bool flag3 = num >= 1;
                if (flag3)
                {
                    node.Parent.Checked = true;
                    this.ChangeParent(node.Parent);
                }
            }
        }


        private void AboutAuthor_Click(object sender, EventArgs e)
        {
            MessageBox.Show("本程序仅作交流学习用，请勿用于商业用途！使用过程中如遇严重问题请联系作者！\n\n如有软件开发需求，也请联系作者", "关于", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
        }


        private void ResourceBox_TextChanged(object sender, EventArgs e)
        {
            var flag = this.ResourceBox.Text != "";
            if (flag)
            {
                this.AnysisAndAddBtn.Enabled = true;
            }
        }

        private int classCount = 0;

        private int soundsCount = 0;

        private bool userStop = false;

        private bool isStop = false;

        private string storePath = AppDomain.CurrentDomain.BaseDirectory;

        private delegate void DeleUpdateTreeView();
    }
}
